#include "main/utils.h"
using namespace std;

bool compare(int num1, int num2) {
  string str1 = to_string(num1);
  string str2 = to_string(num2);
  string compare_str1 = str1 + str2;
  string compare_str2 = str2 + str1;
  long compare_num1 = atoi(compare_str1.c_str());
  long compare_num2 = atoi(compare_str2.c_str());
  return compare_num1 <= compare_num2;
}

int convertToMinNumber(vector<int> vec) {
  sort(vec.begin(), vec.end(), compare);
  string ret_str;
  for (int i = 0; i < vec.size(); ++i) {
    ret_str += to_string(vec[i]);
  }
  long ret = atoi(ret_str.c_str());
  return ret;
}

int main() {
  vector<int> vec = {3, 32, 321};
  long ret = convertToMinNumber(vec);
  cout << "The vector convert to minmum number is: " << ret << endl;

  return 0;
}
